# -*- coding: iso-8859-15 -*-

__svninfo__ = "$Id$"

from cadastro.base import *
from classe.cliente import *

from lib.find import FindCliente

class WinCliente(WinCadastro):

	def __init__(self, ws):

		glade_dict = {
			'arquivo': 'cliente.glade',
			'janela': 'cliente',
		}

		tv_info = [
			('Codigo', 	'codigo', 	'int', 		1.0, 70,	False, TInteger),
			('Nome', 	'nome', 	'string', 	0.0, 250,	False, TString),
			('CPF', 	'cpf',		'string', 	0.0, 150,	False, TString),
		]

		fill_sql = "select * from cliente order by codigo"

		classe = Cliente

		prefixo = 'cliente'

		rf = [
			('nome', 'o nome do cliente'),
		]
		
		WinCadastro.__init__(self, ws, glade_dict, tv_info, fill_sql, classe, prefixo, FindCliente, rf)

	def on_bt_find_clicked(self, *args):
		self.on_find()

	def on_bt_edit_clicked(self, *args):
		self.bt_edit(args)

	def on_bt_add_clicked(self, *args):
		self.bt_add(args)

	def on_bt_del_clicked(self, *args):
		self.bt_del(args)

	def quit(self, *args):
	
		self.w._top.destroy()
		gtk.main_quit()


if __name__ == '__main__':
	from lib.workspace import *
	ws = workspace()
	d = {'dbname': 'germano', 'host': 'localhost', 'user': 'postgres'}
	if ws.connect_db(d):
		ws.user = {'grid': -1, 'funcionario': 1}
		WinCliente(ws).show()
